/**
 * 抽象方法设置继承必须设置的值
 * 类继承时方法覆盖
 */
import { FC } from 'react';

import { Content, Header } from '@/components/Page';

abstract class TestStore1 {
  abstract get param1(): string;

  handleFun1 = () => {
    console.log('我是TestStore1');
  };

  handleGetParam1 = () => {
    console.log(this.param1);
  };
}

class TestStore2 extends TestStore1 {
  get param1(): string {
    return '参数1';
  }
  // 同名方法会覆盖继承中类的
  handleFun1 = () => {
    console.log('我是TestStore2', this.handleGetParam1());
  };
}

const store = new TestStore2();

const Extends: FC = () => {
  store.handleFun1();
  store.handleGetParam1();

  return (
    <>
      <Header title="继承类" backPath="/test-pages" />
      <Content>继承类-控制台查看</Content>
    </>
  );
};

export default Extends;
